/* AI聊天样式文件 */

/* AI 气泡样式 */
.ai-bubble {
	position: fixed;
	bottom: 40px;
	right: 40px;
	width: 64px;
	height: 64px;
	background: #FFFFFF;
	border: 1px solid #E5E7EB;
	border-radius: 999px;
	display: flex;
	align-items: center;
	justify-content: center;
	cursor: pointer;
	box-shadow: 0 8px 20px rgba(16, 24, 40, 0.08);
	z-index: 100;
	transition: all 0.3s ease;
}

/* AI聊天窗口展开时，气泡位置调整 */
.ai-chat.open + .ai-bubble,
.ai-chat.open ~ .ai-bubble {
    right: calc(500px + 20px);
}

/* 使用CSS变量动态调整气泡位置 */
.ai-chat.open + .ai-bubble,
.ai-chat.open ~ .ai-bubble {
    right: calc(var(--chat-width, 500px) + 20px);
}

.ai-bubble svg {
	width: 40px;
	height: 40px;
	display: block;
}

.ai-bubble:hover {
	transform: translateY(-2px);
	box-shadow: 0 12px 28px rgba(16, 24, 40, 0.12);
}

.ai-bubble:active {
	transform: translateY(0);
}

.ai-bubble:focus-visible {
	outline: none;
	box-shadow: 0 0 0 4px rgba(42, 92, 170, 0.15), 0 8px 20px rgba(16, 24, 40, 0.08);
}

@media (max-width: 480px) {
	.ai-bubble {
		bottom: 20px;
		right: 20px;
		width: 60px;
		height: 60px;
	}
	.ai-bubble svg {
		width: 34px;
		height: 34px;
	}
}


.ai-bubble span {
    display: none;
    color: #2A5CAA;
    font-size: 24px;
    filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.1));
}

/* 当iconify-icon不可见时显示备用图标 */
.ai-bubble:not(:has(iconify-icon:not([style*="display: none"]))) span {
    display: block;
}

/* AI聊天窗口 */
.ai-chat {
    position: fixed;
    top: 0;
    right: 0;
    width: 500px;
    min-width: 400px;
    max-width: 800px;
    height: 100vh;
    background-color: white;
    box-shadow: -4px 0 24px rgba(0, 0, 0, 0.15);
    z-index: 1000;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    transform: translateX(100%);
    transition: all 0.3s ease;
    resize: horizontal;
}

/* 无动画状态 */
.ai-chat.no-animation {
    transition: none !important;
}

/* 暂停动画状态 */
.ai-chat.paused-animation {
    animation-play-state: paused;
}

.ai-chat.open {
    transform: translateX(0);
}

/* 拖拽时的样式优化 */
.ai-chat.resizing {
    user-select: none;
}

.ai-chat.resizing * {
    pointer-events: none;
}

.ai-chat.resizing .chat-header {
    pointer-events: auto;
}

/* 聊天头部 */
.chat-header {
    padding: 20px;
    border-bottom: 1px solid #EAEEF4;
    font-weight: 600;
    font-size: 18px;
    background-color: #F9FAFC;
    display: flex;
    justify-content: space-between;
    align-items: center;
    position: relative;
}


/* 整个聊天窗口左侧的拖拽区域 */
.ai-chat::before {
    content: '';
    position: absolute;
    left: 0;
    top: 0;
    width: 4px;
    height: 100%;
    background: linear-gradient(to bottom, #E5E7EB, #D1D5DB);
    cursor: ew-resize;
    transition: background 0.2s ease;
    z-index: 1;
}

/* 拖拽提示 */
.chat-header::after {
    content: '⋮⋮';
    position: absolute;
    left: 8px;
    top: 50%;
    transform: translateY(-50%);
    font-size: 12px;
    color: #9CA3AF;
    opacity: 0;
    transition: opacity 0.2s ease;
    pointer-events: none;
}

.chat-header:hover::after {
    opacity: 1;
}

.chat-header:hover::before {
    background: linear-gradient(to bottom, #2A5CAA, #1e4788);
    width: 6px;
}

/* 拖拽时的视觉反馈 */
.chat-header.resizing::before {
    background: linear-gradient(to bottom, #2A5CAA, #1e4788);
    width: 6px;
}

/* 整个聊天窗口拖拽时的视觉反馈 */
.ai-chat.resizing::before {
    background: linear-gradient(to bottom, #2A5CAA, #1e4788);
    width: 6px;
}

.chat-close {
    background: none;
    border: none;
    font-size: 24px;
    color: #6B7280;
    cursor: pointer;
    padding: 4px;
    border-radius: 4px;
    transition: all 0.2s;
}

.chat-close:hover {
    background: #E5E7EB;
    color: #374151;
}

/* 聊天消息区域 */
.chat-messages {
    flex: 1;
    padding: 20px;
    overflow-y: auto;
    background: #FAFBFC;
}

.message {
    margin-bottom: 16px !important;
    max-width: 85% !important;
    padding: 12px 16px !important;
    border-radius: 12px !important;
    font-size: 14px !important;
    line-height: 1.5 !important;
    display: block !important;
}

.user-message {
    background: linear-gradient(135deg, #2A5CAA, #1e4788) !important;
    color: white !important;
    margin-left: auto !important;
    border-bottom-right-radius: 4px !important;
}

.ai-message {
    background: #FFFFFF !important;
    color: #1F2937 !important;
    margin-right: auto !important;
    border-bottom-left-radius: 4px !important;
    border: 1px solid #E5E7EB !important;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05) !important;
}

/* AI消息内容容器样式 */
.ai-message-content {
    width: 100%;
}

.ai-message-content p {
    margin: 0 0 8px 0;
}

.ai-message-content p:last-child {
    margin-bottom: 0;
}

/* 流式消息样式 */
.message.streaming {
    background: #F0F8FF;
    border: 2px solid #4FC3F7;
    animation: pulse 1.5s infinite;
}

@keyframes pulse {
    0% { border-color: #4FC3F7; }
    50% { border-color: #29B6F6; }
    100% { border-color: #4FC3F7; }
}

/* 聊天输入区域 */
.chat-input {
    display: flex;
    padding: 20px;
    border-top: 1px solid #EAEEF4;
    background: #FFFFFF;
    gap: 12px;
}

.chat-input input {
    flex: 1;
    padding: 12px 16px;
    border: 1px solid #E5E7EB;
    border-radius: 8px;
    font-size: 14px;
    transition: border-color 0.2s;
}

.chat-input input:disabled {
    background: #F9FAFB;
    color: #6B7280;
    cursor: not-allowed;
}

.chat-input input:focus {
    outline: none;
    border-color: #2A5CAA;
    box-shadow: 0 0 0 3px rgba(42, 92, 170, 0.1);
}

.chat-input button {
    background: #2A5CAA;
    color: white;
    border: none;
    padding: 12px 20px;
    border-radius: 8px;
    cursor: pointer;
    font-weight: 500;
    transition: background-color 0.2s;
}

.chat-input button:hover {
    background: #1e4788;
}

.chat-input button:disabled {
    background: #9CA3AF;
    cursor: not-allowed;
}

/* 滚动条隐藏 */
.hide-scrollbar::-webkit-scrollbar {
    display: none;
}

.hide-scrollbar {
    -ms-overflow-style: none;
    scrollbar-width: none;
}

/* 响应式设计 */
@media (max-width: 768px) {
    .ai-chat {
        width: 100%;
        min-width: 100%;
        max-width: 100%;
    }
    
    .ai-bubble {
        bottom: 20px;
        right: 20px;
        width: 56px;
        height: 56px;
    }
    
    /* 移动端不调整气泡位置 */
    .ai-chat.open + .ai-bubble,
    .ai-chat.open ~ .ai-bubble {
        right: 20px;
    }
    
    .chat-header {
        padding: 16px;
    }
    
    .chat-messages {
        padding: 16px;
    }
    
    .chat-input {
        padding: 16px;
    }
}

@media (max-width: 480px) {
    .ai-chat {
        width: 100%;
        min-width: 100%;
        max-width: 100%;
    }
    
    .ai-bubble {
        bottom: 16px;
        right: 16px;
        width: 52px;
        height: 52px;
    }
    
    .chat-header {
        padding: 12px;
    }
    
    .chat-messages {
        padding: 12px;
    }
    
    .chat-input {
        padding: 12px;
    }
    
    .message {
        max-width: 90% !important;
        padding: 10px 14px !important;
        font-size: 13px !important;
    }
}

/* Markdown样式 */
.ai-message h1, .ai-message h2, .ai-message h3, .ai-message h4, .ai-message h5, .ai-message h6 {
    margin: 8px 0 4px 0;
    color: #1F2937;
    font-weight: 600;
}

.ai-message h1 { font-size: 18px; }
.ai-message h2 { font-size: 16px; }
.ai-message h3 { font-size: 15px; }
.ai-message h4, .ai-message h5, .ai-message h6 { font-size: 14px; }

.ai-message p {
    margin: 4px 0;
    line-height: 1.5;
}

.ai-message ul, .ai-message ol {
    margin: 4px 0;
    padding-left: 20px;
}

.ai-message li {
    margin: 2px 0;
    line-height: 1.4;
}

.ai-message blockquote {
    margin: 8px 0;
    padding: 8px 12px;
    border-left: 4px solid #E5E7EB;
    background-color: #F9FAFB;
    color: #6B7280;
    font-style: italic;
}

.ai-message code {
    background-color: #F3F4F6;
    padding: 2px 6px;
    border-radius: 4px;
    font-family: 'Monaco', 'Menlo', 'Ubuntu Mono', monospace;
    font-size: 13px;
    color: #DC2626;
}

.ai-message pre {
    background-color: #1F2937;
    color: #F9FAFB;
    padding: 12px;
    border-radius: 6px;
    overflow-x: auto;
    margin: 8px 0;
}

.ai-message pre code {
    background-color: transparent;
    color: inherit;
    padding: 0;
}

.ai-message strong {
    font-weight: 600;
    color: #111827;
}

.ai-message em {
    font-style: italic;
    color: #374151;
}

.ai-message a {
    color: #2563EB;
    text-decoration: none;
}

.ai-message a:hover {
    text-decoration: underline;
}

.ai-message table {
    border-collapse: collapse;
    width: 100%;
    margin: 8px 0;
}

.ai-message th, .ai-message td {
    border: 1px solid #E5E7EB;
    padding: 6px 8px;
    text-align: left;
}

.ai-message th {
    background-color: #F9FAFB;
    font-weight: 600;
}

.ai-message hr {
    border: none;
    border-top: 1px solid #E5E7EB;
    margin: 12px 0;
}
